package com.net.oil.user.presenter;

import com.net.oil.base.BasePresenter;
import com.net.oil.user.bean.CheckPhoneBean;
import com.net.oil.user.contract.ResetLoginPasswordContract;
import com.net.oil.user.model.ResetLoginPasswordModel;

/**
 * 作者：lch
 * 时间：2018/4/2:14:08
 * 邮箱：245850413@qq.com
 * 说明：
 */

public class ResetLoginPasswordPresenter extends BasePresenter<ResetLoginPasswordContract.View> implements ResetLoginPasswordContract.Presenter {

    private ResetLoginPasswordContract.View view;
    private ResetLoginPasswordContract.Model model;

    public ResetLoginPasswordPresenter(ResetLoginPasswordContract.View view) {
        this.view = view;
        model = new ResetLoginPasswordModel(this);
    }

    @Override
    protected void unSubscribe() {
        model.unSubscribe();
    }

    /**
     * 验证手机号是否注册
     * @param phone 手机号
     */
    @Override
    public void checkPhone(String phone) {
        model.checkPhone(phone);
    }

    /**
     * 验证手机号成功
     * @param checkPhoneBean  返回数据
     */
    @Override
    public void checkPhoneSuccess(CheckPhoneBean checkPhoneBean) {
        view.checkPhoneSuccess(checkPhoneBean);
    }

    /**
     * 验证手机号失败
     */
    @Override
    public void checkPhoneFailed() {
        view.checkPhoneFailed();
    }

    @Override
    public void getPhoneCode(String phone, boolean ptt) {
        model.getPhoneCode(phone, ptt);
    }

    @Override
    public void getPhoneCodeSuccess() {
        view.getPhoneCodeSuccess();
    }

    @Override
    public void getPhoneCodeFailed() {
        view.getPhoneCodeFailed();
    }

    @Override
    public void verifyCode(String phone, String code) {
        model.verifyCode(phone, code);
    }

    @Override
    public void verifyCodeSuccess() {
        view.verifyCodeSuccess();
    }

    @Override
    public void verifyCodeFailed() {
        view.verifyCodeFailed();
    }

    @Override
    public void resetLoginPassword(String phone, String code, String newPassword) {
        model.resetLoginPassword(phone, code, newPassword);
    }

    @Override
    public void resetLoginPasswordSuccess() {
        view.resetLoginPasswordSuccess();
    }

    @Override
    public void resetLoginPasswordFailed() {
        view.resetLoginPasswordFailed();
    }
}
